package com.campuscarbooking.api.dto;

import lombok.Data;
import org.springframework.data.domain.Page;

import java.util.List;

@Data
public class PageResponse<T> {
    private List<T> items;
    private long total;
    private int page;
    private int pageSize;

    public static <T, E> PageResponse<T> from(Page<E> page, List<T> items) {
        PageResponse<T> response = new PageResponse<>();
        response.setItems(items);
        response.setTotal(page.getTotalElements());
        response.setPage(page.getNumber());
        response.setPageSize(page.getSize());
        return response;
    }
} 